// ----------------------------------------------------------------------------
// serialize_pointer_type.h
// ----------------------------------------------------------------------------
#pragma once
#include <fw/base/serialize/serialize_type.h>
#include <fw/base/runtime/hash.h>


namespace fw
{
	class ByteReader;
	class ByteWriter;
	class SerializePointerValue;
	
	class SerializePointerType : public SerializeType
	{
	private:
		const SerializeType*	m_indirectType;
		
	public:
		SerializePointerType(const SerializeType* indirectType);
		
		virtual SerializeStatus			ConvertOne		(char*					dstData,
														 const char*			srcData,
														 const SerializeType*	srcType,
														 SerializeAllocator&	allocator,
														 int					arrayCount=1) const;
		
		virtual size_t					GetSize			() const;
		virtual size_t					GetAlignment	() const;
		
		virtual bool					IsTerminal		(const char*					data,
														 const SerializeScalarValue&	terminatorValue,
														 Hash							terminatorName) const;
		
		virtual bool					IsBuiltIn		() const
		{
			return true;
		}
		
		virtual void					Write			(ByteWriter& writer) const
		{ // Pointer types are builtin.
		}
		
		virtual uint64_t				GetChecksum		(uint64_t basis) const
		{
			return basis;
		}
		
		virtual SerializeStatus			FixUp			(class SerializeSchema& schema);
		
		virtual SerializePointerValue	ReadPointerValue(const char* data) const;
		
		virtual void					WritePointerValue(char* data, const SerializePointerValue& value) const;
		
		virtual const SerializeType*	GetIndirectType	() const
		{
			return m_indirectType;
		}
		
		virtual const SerializePointerType* AsPointerType() const
		{
			return this;
		}
		
	}; // class SerializePointerType
	
} // namespace fw
